Preliminaries
Load packages
xxxxxxxxxxbegin using Empirikos using DataFrames using MosekTools using LaTeXStrings using Plots pgfplotsx()endLoad the Moving to Opportunities neighborhoods dataset (Chetty and Hendren, 2018) and remove missing entries
| CZ | Name_of_CZ | Census_2000_population | State_Abbrev. | State | Urban_Areas | p25_coef | p25_se | p25_se_boot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Int64 | String | Float64 | String | String | Int64 | Float64 | Float64 | Float64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1 | 100 | "Johnson City" | 576081.0 | "TN" | "Tennessee" | 1 | -0.416 | 0.25 | 0.273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 200 | "Morristown" | 227816.0 | "TN" | "Tennessee" | 1 | -0.043 | 0.249 | 0.266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 301 | "Middlesborough" | 66708.0 | "TN" | "Tennessee" | 0 | 0.428 | 0.568 | 0.578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 302 | "Knoxville" | 727600.0 | "TN" | "Tennessee" | 1 | -0.055 | 0.183 | 0.187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 401 | "Winston-Salem" | 493180.0 | "NC" | "North Carolina" | 1 | -0.443 | 0.199 | 0.201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 402 | "Martinsville" | 92753.0 | "VA" | "Virginia" | 0 | -0.47 | 0.413 | 0.411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 500 | "Greensboro" | 1.05513e6 | "NC" | "North Carolina" | 1 | -0.347 | 0.132 | 0.134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 601 | "North Wilkesboro" | 90016.0 | "NC" | "North Carolina" | 0 | 0.237 | 0.572 | 0.519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 602 | "Galax" | 64676.0 | "VA" | "Virginia" | 0 | -1.085 | 0.692 | 0.806 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 700 | "Spartanburg" | 354533.0 | "SC" | "South Carolina" | 1 | -0.233 | 0.23 | 0.243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 39400 | "Seattle" | 3.77574e6 | "WA" | "Washington" | 1 | 0.229 | 0.082 | 0.089 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
xxxxxxxxxxnbhood_csv = Empirikos.Neighborhoods.load_table() |> DataFrame |> dropmissingWrap the data in a type that represents the Gaussian likelihood:
Z= -0.416 | σ=0.25
Z= -0.043 | σ=0.249
Z= 0.428 | σ=0.568
Z= -0.055 | σ=0.183
Z= -0.443 | σ=0.199
Z= -0.47 | σ=0.413
Z= -0.347 | σ=0.132
Z= 0.237 | σ=0.572
Z= -1.085 | σ=0.692
Z= -0.233 | σ=0.23
Z= -0.402 | σ=0.2
Z= -0.248 | σ=0.096
Z= 0.86 | σ=0.601
Z= -0.386 | σ=0.353
Z= -0.007 | σ=0.222
Z= -0.693 | σ=0.763
Z= 0.692 | σ=0.848
Z= -0.425 | σ=0.239
Z= -0.172 | σ=0.759
Z= 0.052 | σ=0.358
Z= 0.141 | σ=0.51
Z= -0.053 | σ=0.135
Z= -0.258 | σ=0.348
Z= 0.243 | σ=0.248
Z= -0.171 | σ=0.212
Z= 0.807 | σ=0.59
Z= 0.19 | σ=0.258
Z= 0.331 | σ=0.355
Z= 0.723 | σ=0.424
Z= 0.229 | σ=0.082
xxxxxxxxxxZs = NormalSample.(nbhood_csv.p25_coef, nbhood_csv.p25_se)Let us define the empirical Bayes targets we want to estimate. We will estimate
xxxxxxxxxxmd" Let us define the empirical Bayes targets we want to estimate. We will estimate $\mathbb E[\mu \mid Z=z, σ = σ]$ where we vary $\sigma \in \{0.5, 1, 2\}$ and $z \in \{-3\sigma, -2.9\sigma,\dotsc, 2.9\sigma, 3\sigma\}$."1×3 Array{Float64,2}:
0.5 1.0 2.0xxxxxxxxxxσs = [0.5 1.0 2.0]61×3 Array{PosteriorMean{NormalSample{Float64,Float64}},2}:
PosteriorMean{NormalSample{Float64,Float64}}(Z= -1.5 | σ=0.5 ) … PosteriorMean{NormalSample{Float64,Float64}}(Z= -6.0 | σ=2.0 )
PosteriorMean{NormalSample{Float64,Float64}}(Z= -1.45 | σ=0.5 ) PosteriorMean{NormalSample{Float64,Float64}}(Z= -5.8 | σ=2.0 )
PosteriorMean{NormalSample{Float64,Float64}}(Z= -1.4 | σ=0.5 ) PosteriorMean{NormalSample{Float64,Float64}}(Z= -5.6 | σ=2.0 )
PosteriorMean{NormalSample{Float64,Float64}}(Z= -1.35 | σ=0.5 ) PosteriorMean{NormalSample{Float64,Float64}}(Z= -5.4 | σ=2.0 )
PosteriorMean{NormalSample{Float64,Float64}}(Z= -1.3 | σ=0.5 ) PosteriorMean{NormalSample{Float64,Float64}}(Z= -5.2 | σ=2.0 )
PosteriorMean{NormalSample{Float64,Float64}}(Z= -1.25 | σ=0.5 ) … PosteriorMean{NormalSample{Float64,Float64}}(Z= -5.0 | σ=2.0 )
PosteriorMean{NormalSample{Float64,Float64}}(Z= -1.2 | σ=0.5 ) PosteriorMean{NormalSample{Float64,Float64}}(Z= -4.8 | σ=2.0 )
⋮ ⋱
PosteriorMean{NormalSample{Float64,Float64}}(Z= 1.25 | σ=0.5 ) … PosteriorMean{NormalSample{Float64,Float64}}(Z= 5.0 | σ=2.0 )
PosteriorMean{NormalSample{Float64,Float64}}(Z= 1.3 | σ=0.5 ) PosteriorMean{NormalSample{Float64,Float64}}(Z= 5.2 | σ=2.0 )
PosteriorMean{NormalSample{Float64,Float64}}(Z= 1.35 | σ=0.5 ) PosteriorMean{NormalSample{Float64,Float64}}(Z= 5.4 | σ=2.0 )
PosteriorMean{NormalSample{Float64,Float64}}(Z= 1.4 | σ=0.5 ) PosteriorMean{NormalSample{Float64,Float64}}(Z= 5.6 | σ=2.0 )
PosteriorMean{NormalSample{Float64,Float64}}(Z= 1.45 | σ=0.5 ) PosteriorMean{NormalSample{Float64,Float64}}(Z= 5.8 | σ=2.0 )
PosteriorMean{NormalSample{Float64,Float64}}(Z= 1.5 | σ=0.5 ) … PosteriorMean{NormalSample{Float64,Float64}}(Z= 6.0 | σ=2.0 )xxxxxxxxxxtargets = PosteriorMean.(NormalSample.(collect(-3:0.1:3) .* σs, σs))1×3 Array{LaTeXString,2}:
L"$E[\mu \mid Z=z, \sigma=0.5]$" … L"$E[\mu \mid Z=z, \sigma=2.0]$"xxxxxxxxxxtarget_names = [L"E[\mu \mid Z=z, \sigma=%$σ]" for σ in σs]Smooth prior class
Throughout this Section we first assume that the true prior
MixturePriorClass (K = 601)
Distributions.Normal{Float64}(μ=-3.0, σ=0.25)
Distributions.Normal{Float64}(μ=-2.99, σ=0.25)
Distributions.Normal{Float64}(μ=-2.98, σ=0.25)
Distributions.Normal{Float64}(μ=-2.97, σ=0.25)
Distributions.Normal{Float64}(μ=-2.96, σ=0.25)
Distributions.Normal{Float64}(μ=-2.95, σ=0.25)
Distributions.Normal{Float64}(μ=-2.94, σ=0.25)
Distributions.Normal{Float64}(μ=-2.93, σ=0.25)
The rest are omitted ...
xxxxxxxxxxgcal_smooth = MixturePriorClass(Normal.(-3:0.01:3, 0.25))We start by fitting the NPMLE to that prior class (this is not needed for the intervals).
xxxxxxxxxxnpmle_smooth_fit = fit(NPMLE(gcal_smooth, Mosek.Optimizer), Zs);xxxxxxxxxxplot( -3:0.001:3, x -> pdf(npmle_smooth_fit.prior, x), xguide = L"\mu", yguide = L"g(\mu)", title = "NPMLE prior estimate", label = nothing, size = (400,200))Start with confidence interval construction (compound DKW-F-Localization)
0.05
1000
MixturePriorClass (K = 601)
Distributions.Normal{Float64}(μ=-3.0, σ=0.25)
Distributions.Normal{Float64}(μ=-2.99, σ=0.25)
Distributions.Normal{Float64}(μ=-2.98, σ=0.25)
Distributions.Normal{Float64}(μ=-2.97, σ=0.25)
Distributions.Normal{Float64}(μ=-2.96, σ=0.25)
Distributions.Normal{Float64}(μ=-2.95, σ=0.25)
Distributions.Normal{Float64}(μ=-2.94, σ=0.25)
Distributions.Normal{Float64}(μ=-2.93, σ=0.25)
The rest are omitted ...
Optimizer (generic function with 2 methods)
100
xxxxxxxxxxfloc_method_smooth = FLocalizationInterval(; flocalization = DvoretzkyKieferWolfowitz(0.05), convexclass = gcal_smooth, solver = Mosek.Optimizer,)61×3 Array{Empirikos.LowerUpperConfidenceInterval,2}:
lower = -1.244, upper = -0.2099, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -1.5 | σ=0.5 )) … lower = -1.587, upper = 0.01869, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -6.0 | σ=2.0 ))
lower = -1.113, upper = -0.1999, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -1.45 | σ=0.5 )) lower = -1.465, upper = 0.02154, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -5.8 | σ=2.0 ))
lower = -0.9878, upper = -0.1899, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -1.4 | σ=0.5 )) lower = -1.344, upper = 0.02484, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -5.6 | σ=2.0 ))
lower = -0.8702, upper = -0.1799, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -1.35 | σ=0.5 )) lower = -1.224, upper = 0.02792, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -5.4 | σ=2.0 ))
lower = -0.7615, upper = -0.1699, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -1.3 | σ=0.5 )) lower = -1.108, upper = 0.031, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -5.2 | σ=2.0 ))
lower = -0.6629, upper = -0.1591, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -1.25 | σ=0.5 )) … lower = -0.9958, upper = 0.03407, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -5.0 | σ=2.0 ))
lower = -0.5747, upper = -0.144, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -1.2 | σ=0.5 )) lower = -0.889, upper = 0.03715, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -4.8 | σ=2.0 ))
⋮ ⋱
lower = 0.304, upper = 0.9541, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= 1.25 | σ=0.5 )) … lower = 0.1529, upper = 1.584, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= 5.0 | σ=2.0 ))
lower = 0.3213, upper = 1.049, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= 1.3 | σ=0.5 )) lower = 0.156, upper = 1.691, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= 5.2 | σ=2.0 ))
lower = 0.3318, upper = 1.142, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= 1.35 | σ=0.5 )) lower = 0.1591, upper = 1.797, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= 5.4 | σ=2.0 ))
lower = 0.3418, upper = 1.24, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= 1.4 | σ=0.5 )) lower = 0.1621, upper = 1.902, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= 5.6 | σ=2.0 ))
lower = 0.3518, upper = 1.337, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= 1.45 | σ=0.5 )) lower = 0.1654, upper = 2.004, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= 5.8 | σ=2.0 ))
lower = 0.3618, upper = 1.429, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= 1.5 | σ=0.5 )) … lower = 0.1683, upper = 2.102, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= 6.0 | σ=2.0 ))xxxxxxxxxxpostmean_cis_smooth = confint.(floc_method_smooth, targets,Zs)Also evaluate the plugin estimates based on the NPMLE and finally plot everything (interval bands in blue, NPMLE estimate in dashed purple and z ↦ z dotted black).
xxxxxxxxxxtargets_smooth_npmle = targets.(npmle_smooth_fit.prior);x
beginplots_smooth = plot.(Ref(-3:0.1:3),eachcol(postmean_cis_smooth), xlabel = L"z / \sigma", label = "")plot!.( plots_smooth, Ref(-3:0.1:3.0), eachcol(response.(location.(targets))), label = "", seriestype = :line, linestyle = :dot, seriescolor = :gray,)plot!.( plots_smooth, Ref(-3:0.1:3.0), eachcol(targets_smooth_npmle), label = "", seriestype = :line, linecolor = :purple, linestyle = :dash,)plot(plots_smooth..., ylabel = target_names, layout=(1,3), size=(600,200))endDiscrete class
Now instead we make a more standard nonparametric EB assumption, i.e. that
DiscretePriorClass | support = -3.0:0.01:3.0xxxxxxxxxxdiscrete_class = Empirikos.DiscretePriorClass(-3:0.01:3)xxxxxxxxxxnpmle_discrete_fit = fit(NPMLE(discrete_class, Mosek.Optimizer), Zs);xxxxxxxxxxplot( support(npmle_discrete_fit.prior), probs(npmle_discrete_fit.prior), seriestype = :sticks, xguide = L"\mu", yguide = L"g(\mu)", title = "NPMLE prior estimate", label = nothing, size = (400,200))0.05
1000
DiscretePriorClass | support = -3.0:0.01:3.0
Optimizer (generic function with 2 methods)
100
xxxxxxxxxxfloc_method_discrete = FLocalizationInterval(; flocalization = DvoretzkyKieferWolfowitz(0.05), convexclass = discrete_class, solver = Mosek.Optimizer,)61×3 Array{Empirikos.LowerUpperConfidenceInterval,2}:
lower = -1.709, upper = 0.09511, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -1.5 | σ=0.5 )) … lower = -1.96, upper = 0.09678, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -6.0 | σ=2.0 ))
lower = -1.562, upper = 0.09512, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -1.45 | σ=0.5 )) lower = -1.851, upper = 0.09713, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -5.8 | σ=2.0 ))
lower = -1.413, upper = 0.09512, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -1.4 | σ=0.5 )) lower = -1.737, upper = 0.09728, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -5.6 | σ=2.0 ))
lower = -1.265, upper = 0.09513, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -1.35 | σ=0.5 )) lower = -1.62, upper = 0.09766, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -5.4 | σ=2.0 ))
lower = -1.119, upper = 0.09513, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -1.3 | σ=0.5 )) lower = -1.5, upper = 0.09824, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -5.2 | σ=2.0 ))
lower = -0.977, upper = 0.1022, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -1.25 | σ=0.5 )) … lower = -1.38, upper = 0.09901, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -5.0 | σ=2.0 ))
lower = -0.8433, upper = 0.1089, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -1.2 | σ=0.5 )) lower = -1.26, upper = 0.1, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -4.8 | σ=2.0 ))
⋮ ⋱
lower = 0.01533, upper = 1.175, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= 1.25 | σ=0.5 )) … lower = 0.08832, upper = 1.598, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= 5.0 | σ=2.0 ))
lower = 0.02487, upper = 1.283, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= 1.3 | σ=0.5 )) lower = 0.09044, upper = 1.708, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= 5.2 | σ=2.0 ))
lower = 0.04172, upper = 1.382, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= 1.35 | σ=0.5 )) lower = 0.09243, upper = 1.816, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= 5.4 | σ=2.0 ))
lower = 0.06855, upper = 1.496, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= 1.4 | σ=0.5 )) lower = 0.09438, upper = 1.921, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= 5.6 | σ=2.0 ))
lower = 0.09328, upper = 1.619, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= 1.45 | σ=0.5 )) lower = 0.09638, upper = 2.022, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= 5.8 | σ=2.0 ))
lower = 0.1057, upper = 1.731, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= 1.5 | σ=0.5 )) … lower = 0.09841, upper = 2.117, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= 6.0 | σ=2.0 ))xxxxxxxxxxpostmean_cis_discrete = confint.(floc_method_discrete, targets, Zs)61×3 Array{Float64,2}:
-0.0661083 -0.0313622 -0.00599918
-0.0639283 -0.0300027 -0.00496677
-0.0617293 -0.0286258 -0.00391495
-0.0595121 -0.02723 -0.00284286
-0.0572774 -0.025814 -0.00174962
-0.0550258 -0.0243759 -0.000634291
-0.0527579 -0.022914 0.000504118
⋮
0.410241 0.254003 0.139249
0.448052 0.27757 0.147126
0.486403 0.304242 0.155606
0.524787 0.334624 0.164754
0.562703 0.369437 0.174644
0.599696 0.409529 0.185357x
targets_discrete_npmle = targets.(npmle_discrete_fit.prior)x
beginplots_discrete = plot.(Ref(-3:0.1:3), eachcol(postmean_cis_discrete), xlabel = L"z/\sigma", label = "")plot!.( plots_discrete, Ref(-3:0.1:3.0), eachcol(response.(location.(targets))), label = "", seriestype = :line, linestyle = :dot, seriescolor = :gray,)plot!.( plots_discrete, Ref(-3:0.1:3.0), eachcol(targets_discrete_npmle), label = "", seriestype = :line, linecolor = :purple, linestyle = :dash,)plot(plots_discrete..., ylabel = target_names, layout=(1,3), size=(600,200))end1×3 Array{Array{Float64,1},2}:
[-1.5, 1.5] [-3.0, 3.0] [-6.0, 6.0]xxxxxxxxxx[[-3σ;3σ] for σ ∈ σs]AMARI intervals
Here we also show how the AMARI intervals may be computed. We assume that the prior lies in the discrete prior class and also compare AMARI intervals to the compound-F-localization intervals (for the posterior mean of the neighborhood causal effect of Yuma).
| CZ | Name_of_CZ | Census_2000_population | State_Abbrev. | State | Urban_Areas | p25_coef | p25_se | p25_se_boot | |
|---|---|---|---|---|---|---|---|---|---|
| Int64 | String | Float64 | String | String | Int64 | Float64 | Float64 | Float64 | |
| 1 | 38100 | "Yuma" | 302387.0 | "CA" | "California" | 1 | -0.216 | 0.172 | 0.175 |
xxxxxxxxxxyuma_df = filter(:Name_of_CZ => isequal("Yuma"), nbhood_csv)Z= -0.216 | σ=0.172
xxxxxxxxxxyuma_posterior_mean = PosteriorMean(NormalSample(yuma_df.p25_coef[1], yuma_df.p25_se[1]))Let us first look at the plug-in estimate from the NPMLE.
-0.0641787365657269xxxxxxxxxxyuma_posterior_mean(npmle_discrete_fit.prior)Next we compute the compound-F-localization interval:
lower = -0.2179, upper = 0.1232, α = 0.05 (PosteriorMean{NormalSample{Float64,Float64}}(Z= -0.216 | σ=0.172))xxxxxxxxxxci_floc = confint(floc_method_discrete, yuma_posterior_mean, Zs)And finally the AMARI interval.
DiscretePriorClass | support = -3.0:0.01:3.0
0.01
1000
Optimizer (generic function with 2 methods)
nothing
Distributions.DiscreteNonParametric{Float64,Float64,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Array{Float64,1}}(
support: -3.0:0.01:3.0
p: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 … 1.3720672434787157e-6, 6.081756595587953e-7, 2.983556408753117e-7, 1.7533507114523433e-7, 1.1932343416975139e-7, 8.976114118617694e-8, 7.192214655252968e-8, 5.984916643357872e-8, 5.0918732423268294e-8, 4.3894711195395335e-8]
)
DiscretePriorClass | support = -3.0:0.01:3.0
Optimizer (generic function with 2 methods)